//
//  InformationViewController.m
//  Mahjong
//
//  Created by mc on 16/9/18.
//  Copyright © 2016年 Elliot. All rights reserved.
//

#import "InformationViewController.h"
#import "AppTools.h"

#define WIDTH ([UIScreen mainScreen].bounds.size.width)
#define HEIGHT ([UIScreen mainScreen].bounds.size.height)
@interface InformationViewController ()<UITableViewDataSource,UITableViewDelegate>


@property (nonatomic, strong) UIView *backView;
@property (nonatomic, strong) UITableView *tableView;
@end

@implementation InformationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.view.backgroundColor = [UIColor colorWithWhite:0.900 alpha:1.000];
    
    
//    [self addNav];
    [self addTableviewUI];
    
    self.navigationItem.title = @"系统消息";
    
   
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"nav_but_back"] style:(UIBarButtonItemStyleDone) target:self action:@selector(backAction)];
    backItem.tintColor = [UIColor grayColor];
    self.navigationItem.leftBarButtonItem = backItem;
    [self create];
}
-(void)create{
    [AppTools createAFN:@"http://api03.m0571.com/WebJson.aspx?book=GetMessage&page=1&userid=25" success:^(id result) {
        NSLog(@"%@",result);
        
    } error:^(NSError *error) {
        
        
    }];
}
- (void)backAction{
    [self.navigationController popViewControllerAnimated:YES];
}
// 处理导航栏和底部删除按钮
//- (UIStatusBarStyle)preferredStatusBarStyle
//{
//    return UIStatusBarStyleLightContent;
//}
-(void)addNav{
    self.backView = [[UIView alloc] initWithFrame:CGRectMake(0, 20, WIDTH, 40)];
    _backView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_backView];
    
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [backBtn setImage:[UIImage imageNamed:@"nav_but_back"] forState:UIControlStateNormal];
    backBtn.backgroundColor = [UIColor clearColor];
    backBtn.titleLabel.font = [UIFont systemFontOfSize:14];
    [backBtn addTarget:self action:@selector(backBtnAction) forControlEvents:UIControlEventTouchUpInside];
    backBtn.frame = CGRectMake(20, 5, 25, 25);
    [_backView addSubview:backBtn];
    
    UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH / 4, 0, WIDTH / 2, 40)];
    //    lable.backgroundColor = [UIColor redColor];
    lable.text = @"系统消息";
    lable.font = [UIFont systemFontOfSize:20];
    lable.textAlignment = NSTextAlignmentCenter;
    [self.backView addSubview:lable];
    
    
}
-(void)backBtnAction{
    [self.navigationController popViewControllerAnimated:YES];
}
// 信息
- (void)addTableviewUI {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.backView.frame)+10, WIDTH, HEIGHT) style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.backgroundColor = [UIColor whiteColor];
    
    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, HEIGHT/4, 0);
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
    [self.view addSubview:self.tableView];
}

#pragma mark -- UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier = @"RepairTableviewCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        //        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.imageView.image = [UIImage imageNamed:@"mess_but_reply"];
    cell.textLabel.text = @"系统消息";
    cell.detailTextLabel.text = @"您的评价门店做出回应";
//    cell.backgroundColor = [UIColor redColor];
    return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
#pragma mark -- UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return HEIGHT/10;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0.001;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *headerview = [[UIView alloc] init];
    headerview.backgroundColor = [UIColor colorWithWhite:0.900 alpha:1.000];
    
    return headerview;
}
//- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
//- (nullable UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"%@",indexPath);
    //    RepairDetailViewController *repairDetailVC = [[RepairDetailViewController alloc] init];
    //    [self.navigationController pushViewController:repairDetailVC animated:YES];
}

//-(void)viewWillAppear:(BOOL)animated{
//    [super viewWillAppear:YES];
//    self.navigationController.navigationBarHidden = YES;
//}
//-(void)viewWillDisappear:(BOOL)animated{
//    [super viewWillDisappear:YES];
//    self.navigationController.navigationBarHidden = NO;
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
